<?php
	include_once('header.php');
	include_once('menu.php');
	include_once('content.php');
?>

<?php	
if($this->session->userdata('logged_in') && $this->session->userdata('admin')){
		if(isset($zmenene) && $zmenene){
			echo '<p style="color: green; font-weight: bolder;">Údaje boli zmenené!</p>';
			echo '<p style="text-align: center;">' . anchor('people', 'Späť na ľudia') . '</p>';
		} else {
			echo form_open('people/upgrade_person', array('class'=>'jNice'));
			echo form_fieldset();
			echo form_error('name');
			echo '<p>'.form_label('Meno*', 'name');
			echo form_input('name', $person->name, set_value('name')).'</p>';
			echo form_error('surname');
			echo '<p>'.form_label('Priezvisko*', 'surname');
			echo form_input('surname', $person->surname, set_value('surname')).'</p>';
			
			echo form_error('degree');
			echo '<p>'.form_label('Titul pred menom 1', 'degree');
			echo form_input('degree', $person->degree ,set_value('degree')).'</p>';
			
			echo form_error('degree2');
			echo '<p>'.form_label('Titul pred menom 2', 'degree2');
			echo form_input('degree2', $person->degree2 ,set_value('degree2')).'</p>';
			echo form_error('degree3');
			echo '<p>'.form_label('Titul za menom', 'degree3');
			echo form_input('degree3', $person->degree3 ,set_value('degree3')).'</p>';
			$selected_m = FALSE; $selected_z = FALSE;
			if($person->sex == 'muz') $selected_m = TRUE;
			elseif($person->sex == 'zena') $selected_z = TRUE;
			
			echo form_error('sex');
			echo '<p>'.form_label('Muž', 'sex');
			echo form_radio('sex[]','muz', $selected_m).'</p>';
			echo '<p>'.form_label('Žena', 'sex');
			echo form_radio('sex[]','zena',$selected_z).'</p>';
			
			echo form_error('sektion');
			echo '<p>'.form_label('Sekcia', 'sektion');
			echo form_input('sektion',$person->sektion ,set_value('sektion')).'</p>';
			echo form_error('department');
			echo '<p>'.form_label('Oddelenie*', 'department');
			echo form_input('department',$person->department ,set_value('department')).'</p>';
			echo form_error('chair');
			echo '<p>'.form_label('Kancelária', 'chair');		
			echo form_input('chair',$person->chair ,set_value('chair')).'</p>';
			echo form_error('email');
			echo '<p>'.form_label('Emailová adresa*', 'email');
			echo form_input('email',$person->email ,set_value('email')).'</p>';
			echo form_error('tel');
			echo '<p>'.form_label('Telefónne číslo', 'tel');
			echo form_input('tel',$person->tel ,set_value('tel')).'</p>';
			echo form_error('web_address');
			echo '<p>'.form_label('Webstránka', 'web_address');
			echo form_input('web_address',$person->web_address ,set_value('web_address')).'</p>';
            $is_deployed_1 = $person->is_deployed == 1 ? TRUE : FALSE;
            $is_deployed_0 = !$is_deployed_1;
			echo form_error('is_deployed');
			echo '<p>'.form_label('Je zamestnaný', 'is_deployed');
			echo 'ano'.form_radio('is_deployed[]','1', $is_deployed_1).'</p>'; 
			echo '<p>nie '.form_radio('is_deployed[]','0', $is_deployed_0).'</p>';
			echo form_error('date_of_birth');
			echo '<p>'.form_label('Dátum narodenia', 'date_of_birth');
			echo form_input('date_of_birth',$person->date_of_birth ,set_value('date_of_birth')).'</p>';
			echo form_hidden('person_id', $person->person_id, set_value('person_id'));
			echo form_submit('zmen','Zmeniť');
			echo form_fieldset_close();
			echo form_close();
			
			echo '<small>Údaje označené * sú povinné!</small>';
		}
}
	?>


<?php

$footer_scripts = '<script type="text/javascript">
jQuery(document).ready(function($) {
    $(\'input[type=text][name=date_of_birth], input[type=text][name=date_of_departure]\').datepicker({ dateFormat: \'yy-mm-dd\', changeMonth: true, changeYear: true, numberOfMonths: 1, showButtonPanel: true, firstDay: 1, showWeek: true, showOtherMonths: true, selectOtherMonths: true, yearRange: \'-150:+0\' });
    $(\'input[type=text][name=degree]\').autocomplete({ source: \'' . site_url('people/getDegree') . '\' });
    $(\'input[type=text][name=degree2]\').autocomplete({ source: \'' . site_url('people/getDegree2') . '\' });
    $(\'input[type=text][name=degree3]\').autocomplete({ source: \'' . site_url('people/getDegree3') . '\' });
    $(\'input[type=text][name=sektion]\').autocomplete({ source: \'' . site_url('people/getSektion') . '\' });
    $(\'input[type=text][name=department]\').autocomplete({ source: \'' . site_url('people/getDepartment') . '\' });
    $(\'input[type=text][name=chair]\').autocomplete({ source: \'' . site_url('people/getChair') . '\' });
});
</script>';
	include_once('footer.php');
?>